home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEV / I-Z / ViewIt™ Shareware.sea / ViewIt™ 2.04 Shareware / Projects / C Demos / vDemoLC.c < prev    next >
Text File  |  1992-08-04  |  4KB  |  117 lines

  1. /* ViewIt 2.03 Demonstration Program */
  2. /* ©FaceWare 1991-92.  All Rights Reserved. */
  3.  
  4. #include "string.h"
  5. #include "FaceStorLC.h"
  6. extern struct FaceRec fRec;
  7.  
  8. short helpShown;
  9. struct {
  10.     short        myInteger;
  11.     float        myReal;
  12.     char        myString[100];
  13.     long        myFlags;
  14.     } myRec;
  15. float theReal;
  16.  
  17. pascal void fJumpIt(Ptr thePtr) = {0x2257,0x2051,0x4E90};
  18.  
  19. pascal void OverProc(Ptr thePtr) {
  20.     float delta;
  21.     ControlHandle theArrow;
  22.     if (fRec.cResID == 1000) {        /* Arrow Controls */
  23.         if (fRec.uCommand == 8) {            /* mouse down message? */
  24.             delta = 0.001 * (fRec.cMin - 2);
  25.             theArrow = fRec.cControl;
  26.             HiliteControl(theArrow,1);
  27.             while (StillDown() == true) {
  28.                 myRec.myReal = myRec.myReal + delta;
  29.                 FaceIt(0L,SetVal,0L,0L,2L,2L);
  30.                 Delay(5,&fRec.uI4);
  31.                 }
  32.             HiliteControl(theArrow,0);
  33.             return;
  34.             }
  35.         }
  36.     else {                                                /* Editable Text Item */
  37.         if (fRec.uCommand == 264)            /* a key down message? */
  38.             if (fRec.uParam[0] == 32)        /* SPACE key pressed? */
  39.                 fRec.uParam[0] = 95;            /* convert to UNDERLINE */
  40.         }
  41.     fJumpIt(thePtr);}                            /* pass message to driver */
  42.  
  43. main()
  44. {
  45.     myRec.myInteger = 0;
  46.     myRec.myReal = 6.2;
  47.     strcpy(myRec.myString,"Hello");
  48.     myRec.myFlags = 10;
  49.     theReal = 6.0;
  50.  
  51. /* Initialize FaceIt */
  52.     strcpy(fRec.uName, "vDemo.Rsrc");
  53.     FaceIt(0L,DoInit,0L,0L,0L,0L);
  54.  
  55. /* Show ViewIt On-Line Help (if available) */
  56.     FaceIt(0L,HlpWnd,0L,0L,10L,10L);
  57.  
  58. /* Open Modeless Window using FWND 1000 */
  59.     FaceIt(0L,NewWnd,1000L,1L,0L,0L);
  60.  
  61.     for (;;) {
  62.         FaceIt(0L,DoLoop,0L,0L,0L,0L);
  63. /* Standard "About" Menu Item Selection */
  64.         if ((fRec.uMenuID == 101L) && (fRec.uMenuItem == 1L)) {
  65.             strcpy(fRec.uString, "Demonstration of the use of ViewIt\rwindows in a FaceIt-based program.");
  66.             FaceIt(0L,ShoStr,3L,12L,(1L + (409L * 65536L)),0L);
  67.             }
  68. /* Hit in Modeless Window's "Open Modal" Button */
  69.         else if ((fRec.uMenuID == 1000L) && (fRec.wcHit == 2L)) {
  70.             FaceIt(0L,NewWnd,1001L,0L,0L,0L);        /* Open Modal Window */
  71.             for (;;) {
  72.                 FaceIt(0L,MdlWnd,1001L,0L,0L,0L);    /* Process Modal Events */
  73.                 if (fRec.wcHit == -1L)                        /* Hit in Close Box */
  74.                     break;
  75.                 else if (fRec.wcHit == 1L) {            /* Hit in "Open Nested" Button */
  76.                     FaceIt(0L,NewWnd,1002L,0L,0L,(long)&myRec);    /* Open Nested Modal */
  77.                     FaceIt(0L,GetCtl,1002L,0L,2L,3L);                        /* Setup Override Examples */
  78.                     FaceIt(0L,OvrCtl,(long)fRec.cControl,(long)&OverProc,0L,0L);
  79.                     FaceIt(0L,GetCtl,1002L,0L,2L,6L);
  80.                     FaceIt(0L,OvrCtl,(long)fRec.cControl,(long)&OverProc,0L,0L);
  81.                     FaceIt(0L,GetCtl,1002L,0L,2L,7L);
  82.                     FaceIt(0L,OvrCtl,(long)fRec.cControl,(long)&OverProc,0L,0L);
  83.                     FaceIt(0L,SetVal,1002L,0L,0L,0L);                        /* Set Linked Values */
  84.                     helpShown = false;
  85.                     for (;;) {
  86.                         FaceIt(0L,MdlWnd,1002L,0L,0L,0L);                    /* Process Modal Events */
  87.                         if (fRec.wvHit == 1L) {                                        /* Hit in View #1 */
  88.                             if (fRec.wcHit == 1L)                                        /* Hit in "OK" Button */
  89.                                 break;
  90.                             else if (fRec.wcHit == 2L) {                        /* Hit in "Show/Hide" */
  91.                                 if (helpShown == true) {
  92.                                     FaceIt(0L,ShoCtl,0L,0L,-3L,2L);            /* Hide v3, Show v2 */
  93.                                     helpShown = false;}
  94.                                 else {
  95.                                     FaceIt(0L,ShoCtl,0L,0L,-2L,3L);            /* Hide v2, Show v3 */
  96.                                     helpShown = true;}
  97.                                 }
  98.                             }
  99.                         }
  100.                     FaceIt(0L,GetVal,1002L,0L,0L,0L);                        /* Get Linked Values */
  101.                     FaceIt(0L,EndWnd,1002L,0L,0L,0L);                        /* Close Nested Modal */
  102.                     }
  103.                 }
  104.             FaceIt(0L,EndWnd,1001L,0L,0L,0L);        /* Close Modal Window */
  105.           }
  106. /* Hit in Modeless Window's "Why ViewIt?" Button */
  107.         else if ((fRec.uMenuID == 1000L) && (fRec.wcHit == 3L)) {
  108.             FaceIt(0L,NewWnd,1003L,0L,0L,(long)&theReal);
  109.             FaceIt(0L,SetVal,1003L,0L,0L,0L);
  110.             for (;;) {
  111.                 FaceIt(0L,MdlWnd,1003L,0L,0L,0L);
  112.                 if (fRec.wcHit == 1L) break;}
  113.             FaceIt(0L,GetVal,1003L,0L,0L,0L);
  114.             FaceIt(0L,EndWnd,1003L,0L,0L,0L);
  115.             }
  116.         }
  117. }